package logic

import (
	"context"
	"ture/models/mysql"

	"ture/turerpc/internal/svc"
	"ture/turerpc/turerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type TrueShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTrueShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TrueShowLogic {
	return &TrueShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TrueShowLogic) TrueShow(in *turerpc.TrueShowRequest) (*turerpc.TrueShowResponse, error) {
	// todo: add your logic here and delete this line

	var ture mysql.True
	mysql.DB.Debug().Where("id=?", in.Id).Find(&ture)
	return &turerpc.TrueShowResponse{
		Title:   ture.Title,
		Name:    ture.Name,
		Price:   float32(ture.Price),
		ClassId: ture.ClassId,
		BrandId: ture.BrandId,
	}, nil
}
